import sys
import networkx as nx
from networkx.algorithms import isomorphism

G1=nx.read_gml(sys.argv[1])
G2=nx.read_gml(sys.argv[2])

G1 = nx.path_graph(4, create_using=nx.DiGraph())
G2 = nx.path_graph(4, create_using=nx.DiGraph())
DiGM = isomorphism.DiGraphMatcher(G1,G2)
if DiGM.match():
    print 'YES'
else:
    print 'NO'
